from matplotlib import pyplot as plt

logpath = './loss/loss_data_T4最新.txt'
color = ['blue']
with open(logpath, "r") as f:
    data = eval(f.readline())

    x = [i for i in range(len(data))]

    plt.figure()

    # 去除顶部和右边框框
    ax = plt.axes()
    ax.spines['top'].set_visible(False)
    ax.spines['right'].set_visible(False)

    plt.xlabel('epoch')
    plt.ylabel(f'loss')

    plt.plot(x, data, color=color[0], linestyle="solid", label=f"loss")
    plt.legend()

    plt.title(f'loss curve')
    plt.show()
    # plt.savefig(f"{mode}.png")
